package com.lanou.utp.controller;

import com.lanou.utp.entity.ResponseData;
import com.lanou.utp.service.ExcelService;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
public class ExcelController {

    @Resource
    private ExcelService excelService;


    @GetMapping("student/model")
    public void outputStudent(HttpServletResponse response){
        this.excelService.outputStudent(response);
    }

    @GetMapping("teacher/model")
    public void outputTeacher(HttpServletResponse response){
        this.excelService.outputTeacher(response);
    }

    @PostMapping("student/import")
    public ResponseData inputStudentModel(MultipartFile file) throws IOException {
            return this.excelService.inputStudentModel(file);
    }

    @PostMapping("teacher/model")
    public ResponseData inputTeacherModel(MultipartFile file) throws IOException {
        return this.excelService.inputTeacherModel(file);
    }

}
